<?php
	class Staff{

		private $id;
		private $imagen;
		private $nombre;
		private $puesto;
		private $facebook;
		private $twitter;
		private $email;
		private $blog;

		public function __construct($id = 0){
			$this->id = $id;
			if($this->id > 0){
				$sql = "SELECT * FROM staff WHERE id_staff = ".$id;
				$query = new Consulta($sql);
				if($query->NumeroRegistros() > 0){
					$row = $query->VerRegistro();
					$this->imagen  		= $row['imagen'];
					$this->nombre 		= $row['nombre'];
					$this->puesto 		= $row['puesto'];
					$this->facebook		= $row['facebook'];
					$this->twitter 		= $row['twitter'];
					$this->email 		= $row['email'];
					$this->blog 		= $row['blog'];
				}					
			}
		}

		public function __get($atributo){
			return $this->$atributo;
		}

		public function getStaff(){
			$sql = "SELECT * FROM staff ORDER BY id_staff DESC";
			$query = new Consulta($sql);
			while( $row = $query->VerRegistro() ){
				$result[] = array(
					'id'		=> $row['id_staff'],
					'imagen'	=> $row['imagen'],
					'nombre' 	=> $row['nombre'],
					'puesto' 	=> $row['puesto'],
					'facebook'	=> $row['facebook'],
					'twitter'	=> $row['twitter'],
					'email' 	=> $row['email'],
					'blog'		=> $row['blog']
				);
			}
			return $result;		
		}

		public function getStaffLimit($ini, $num_reg){
			$sql = "SELECT * FROM noticias ORDER BY id_noticia DESC LIMIT ".$ini.",".$num_reg."";
			$query = new Consulta($sql);
			while( $row = $query->VerRegistro() ){
				$result[] = array(
					'id'		=> $row['id_staff'],
					'imagen'	=> $row['imagen'],
					'nombre' 	=> $row['nombre'],
					'puesto' 	=> $row['puesto'],
					'facebook'	=> $row['facebook'],
					'twitter'	=> $row['twitter'],
					'email' 	=> $row['email'],
					'blog'		=> $row['blog']
				);
			}
			return $result;		
		}

		public function getStaffRand(){
			$sql = "SELECT * FROM staff ORDER BY RAND() LIMIT 1";
			$query = new Consulta($sql);
			while( $row = $query->VerRegistro() ){
				$result[] = array(
					'id'		=> $row['id_staff'],
					'imagen'	=> $row['imagen'],
					'nombre' 	=> $row['nombre'],
					'puesto' 	=> $row['puesto'],
					'facebook'	=> $row['facebook'],
					'twitter'	=> $row['twitter'],
					'email' 	=> $row['email'],
					'blog'		=> $row['blog']
				);
			}
			return $result;		
		}


	}
?>